//! # 配置中心集成测试
//!
//! 提供配置中心的集成测试，验证各模块之间的协同工作。

#[cfg(test)]
mod tests {
    use std::time::Duration;
    
    #[cfg(feature = "client")]
    use crate::client::*;
    
    // 测试核心trait接口
    #[test]
    fn test_core_traits() {
        // 创建测试环境
        let environment = crate::core::ConfigEnvironment::new("test-app", "test", "main");
        
        // 验证ConfigEnvironment
        assert_eq!(environment.application, "test-app");
        assert_eq!(environment.profile, "test");
        assert_eq!(environment.label, "main");
        assert_eq!(environment.key(), "test-app:test:main");
        
        // 验证默认环境
        let default_env = crate::core::ConfigEnvironment::default();
        assert_eq!(default_env.application, "application");
        assert_eq!(default_env.profile, "default");
        assert_eq!(default_env.label, "main");
    }
    
    // 测试配置客户端基本功能
    #[cfg(feature = "client")]
    #[test]
    fn test_config_client_basic() {
        // 创建测试配置
        let config = ConfigClientConfig {
            server_urls: vec!["http://localhost:8888".to_string()],
            application: "test-app".to_string(),
            profile: "test".to_string(),
            label: "main".to_string(),
            connect_timeout: Duration::from_secs(5),
            read_timeout: Duration::from_secs(10),
            retry_count: 3,
            retry_interval: Duration::from_millis(500),
            cache_enabled: true,
            cache_ttl: Duration::from_secs(300),
            refresh_enabled: true,
            refresh_interval: Duration::from_secs(30),
            fail_fast: false,
            auth_token: None,
        };
        
        // 验证配置
        assert_eq!(config.application, "test-app");
        assert_eq!(config.profile, "test");
        assert_eq!(config.label, "main");
        assert_eq!(config.server_urls, vec!["http://localhost:8888"]);
    }
    
    // 测试配置客户端构建器
    #[cfg(feature = "client")]
    #[test]
    fn test_config_client_builder() {
        // 验证构建器可以创建
        let builder = ConfigClient::builder();
        assert!(builder.application("test-app").profile("test").label("main").server_url("http://localhost:8888").build().is_ok());
    }
}